package jdl.databaseObjects.datatypes.postgreSql;

import jdl.databaseObjects.DbType;
import jdl.databaseObjects.DbTypeUnknownException;
import jdl.databaseObjects.datatypes.common.CommonDbTypeFactory;
import jdl.databaseObjects.datatypes.common.TimestampDbType;
import jdl.databaseObjects.datatypes.sqlite.SqliteDbTypeFactory;

public class PostgreSqlDbTypeFactory {
	private PostgreSqlDbTypeFactory() {

	}

	public static DbType createIntegerDbType() {
		return SqliteDbTypeFactory.createIntegerDbType();
	}

	public static DbType createBigintDbType() {
		return SqliteDbTypeFactory.createBigintDbType();
	}

	public static DbType createVarcharDbType(int size) {
		return SqliteDbTypeFactory.createVarcharDbType(size);
	}

	public static DbType createInt2DbType() {
		return new Int2DbType();
	}

	public static DbType createInt4DbType() {
		return new Int4DbType();
	}

	public static DbType createTimestampDbType() {
		return new TimestampDbType();
	}

	public static DbType fromString(String typeName)
			throws DbTypeUnknownException {
		if (typeName.compareToIgnoreCase("int2") == 0)
			return createInt2DbType();
		if (typeName.compareToIgnoreCase("int4") == 0)
			return createInt4DbType();
		return CommonDbTypeFactory.fromString(typeName);
	}
}